package com.utry.ipcc.redis.util;

import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;

public class PropertyUtil {
	private static final Logger log = LoggerFactory.getLogger("publicLog");
	
	private static Properties p;


	public PropertyUtil() {
	}

	public static String getProperties(String name) {
		if (null == name || "".equals(name))
			return null;
		name = name.trim();
		String pFilename = System.getenv("U3C_CONFIG_ROOT") + File.separator + "runtime" + File.separator +"uipccredis.properties"; // 文件名
//		String pFilename = "uipccredis.properties"; // 文件名
    	Properties pro = null;
    	pro = new Properties();
    	try
		{
			pro.load(new FileInputStream(pFilename));
		} catch (FileNotFoundException e)
		{
			pro = null;
			e.printStackTrace();
		} catch (IOException e)
		{
			pro = null;
			e.printStackTrace();
		}
		String propertiesName = pro.getProperty(name);
		if (null != propertiesName)
			propertiesName = propertiesName.trim();
		return propertiesName;
	}

	public static void main(String[] args) {
//		 String str = PropertyUtil.getProperties("uipcc.redis.addr");
		String str = PropertyUtil.getProperties("uipcc.redis.addr");
		System.out.println(".. " + str);
	}

}
